# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=stylus
pkgdesc='Robust, expressive, and feature-rich CSS superset'
pkgver=0.59.0
pkgrel=1
arch=('any')
url='https://github.com/stylus/stylus'
license=('MIT')
depends=('nodejs')
makedepends=('npm' 'git')
source=(https://registry.npmjs.org/$pkgname/-/$pkgname-$pkgver.tgz)
noextract=($pkgname-$pkgver.tgz)
sha512sums=('950f70fd720e1f964754db8d6d65bc0fcdb6afeff00523bf77a5efb721cb17b2d6e0a6822037956ef9f90c5f1f182240502c158558bf87a274354727ca55048e')

package() {
  npm install -g --prefix "$pkgdir"/usr "$srcdir"/$pkgname-$pkgver.tgz

  # Non-deterministic race in npm gives 777 permissions to random directories.
  # See https://github.com/npm/npm/issues/9359 for details.
  chmod -R u=rwX,go=rX "$pkgdir"

  # npm installs package.json owned by build user
  # https://bugs.archlinux.org/task/63396
  chown -R root:root "$pkgdir"

  mkdir -p "$pkgdir/usr/share/licenses/$pkgname"
  ln -s "../../../lib/node_modules/$pkgname/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/"
}
